<template>
    <div>
        <el-form ref="form" :model="recordArchiveslibrary" label-width="80px" >
            <el-form-item label="案件" >
                <el-input v-model="recordArchiveslibrary.caseNo" @focus="showcaselaw" ></el-input>
            </el-form-item>
            <el-form-item label="档案号">
                <el-input v-model="recordArchiveslibrary.recordNum"></el-input>
            </el-form-item>
            <el-form-item label="档案名称">
                <el-input v-model="recordArchiveslibrary.recordName"></el-input>
            </el-form-item>
            <el-form-item label="借档人">
            <el-input v-model="recordArchiveslibrary.borrowFilePeople" @focus="showborrowFilePeople"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" v-model="recordArchiveslibrary.remark"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                <el-button @click="qx">取消</el-button>
            </el-form-item>
        </el-form>
        <el-dialog
                title="提示"
                :visible.sync="dialogVisible"
                width="60%">
            <add-record-ach-law v-if="dialogVisible" v-on:caseNo="setcaseNo"></add-record-ach-law>
        </el-dialog>

        <el-dialog
                title="提示"
                :visible.sync="dialogVisible2"
                width="60%">
            <add-record-ach-emp v-if="dialogVisible2" v-on:userRealname="setborrowFilePeople"></add-record-ach-emp>
        </el-dialog>
    </div>
</template>
<script>
    import AddRecordAchLaw from './AddRecordAchLaw.vue'
    import AddRecordAchEmp from './AddRecordAchEmp.vue'

    import RecordArchiveslibraryService from '../../../model/mfy/onFile/RecordArchiveslibraryService.js'
    var recordArchiveslibraryService=RecordArchiveslibraryService.getInstance();

    export default {
        name: "AddRecordArchiveslibrary",
        data(){
            return{
                recordArchiveslibrary:{},
                dialogVisible:false,
                dialogVisible2:false,

            }
        },
        created() {

        },
        methods:{
            showcaselaw(){
                this.dialogVisible=true
            },
            showborrowFilePeople(){
                this.dialogVisible2=true
            },
            setcaseNo(caseno){
                this.recordArchiveslibrary.caseNo=caseno;
                this.dialogVisible=false;
            },
            setborrowFilePeople(userRealname){
                this.recordArchiveslibrary.borrowFilePeople=userRealname;
                this.dialogVisible2=false;
            },

            qx(){
                this.$emit("qx")
            },
            onSubmit(){

                if(this.recordArchiveslibrary.caseNo=='' || this.recordArchiveslibrary.caseNo==null){
                    this.$message.error("请输入案件!")
                    return;
                }
                if(this.recordArchiveslibrary.recordNum=='' || this.recordArchiveslibrary.recordNum==null){
                    this.$message.error("请输入档案号!")
                    return;
                }
                if(this.recordArchiveslibrary.borrowFilePeople=='' || this.recordArchiveslibrary.borrowFilePeople==null){
                    this.$message.error("请选择借档人!")
                    return;
                }
                if(this.recordArchiveslibrary.recordName=='' || this.recordArchiveslibrary.recordName==null){
                    this.$message.error("请输入档案名称!")
                    return;
                }
                recordArchiveslibraryService.save(this.recordArchiveslibrary).then(()=>{
                    this.$emit("qx")
                })
            }
        },
        components:{
            AddRecordAchLaw,
            AddRecordAchEmp
        }
    }
</script>

<style scoped>

</style>